﻿using System;
using System.Linq.Expressions;
using ApiManage.Core.Repository.MongoDB;
using ApiManage.Models.MongoMappings.Sys;
using Autofac.Extras.DynamicProxy;
using MongoDB.Driver;
using Rhonin.Common.Components;
using Rhonin.Common.UnitOfWork.Transaction;

namespace ApiManage.Applications.Mongo.Sys.Impl
{
    [Component]
    [Intercept(typeof(TransactionInterceptor))]
    public class SysRoleService : ISysRoleService
    {
        private readonly ISysRepository<SysRole> _sysRoleRepository;
        public SysRoleService(ISysRepository<SysRole> sysRoleRepository)
        {
            _sysRoleRepository = sysRoleRepository;
        }


        public void Insert(SysRole param)
        {
            _sysRoleRepository.InsertOne(param);
        }

        public void Update(Expression<Func<SysRole, bool>> fitter, UpdateDefinition<SysRole> updateDefinition)
        {
            _sysRoleRepository.Update(fitter, updateDefinition);
        }
        public void Delete(Expression<Func<SysRole, bool>> fitter)
        {
            _sysRoleRepository.Delete(fitter);
        }
    }
}
